import random
#list1=[]
#for i in range(20):
#    list1.append(random.randint(1,20))\
list1 = [ random.randint(1,20) for i in range(20) ]
print("生产的随机列表为: {}".format(list1))
#dict1={}
#for j in list1:
#    dict1[j]=list1.count(j)
dict1 = { j:list1.count(j) for j in list1 }
print("生成的随机字典为: {}".format(dict1))
print("列表中出现次数排名前三的数字及其个数:")
sorted(dict1.items(),key=lambda x:x[1], reverse=True)[0:3]


# 完成的不错
